package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsTechnologyCommunicate;
import com.ruoyi.system.domain.news.query.NewsTechnologyCommunicateQuery;
import com.ruoyi.system.domain.news.vo.NewsTechnologyCommunicateVo;
import com.ruoyi.system.domain.news.vo.NewsTechnologyCommunicateVo;
import com.ruoyi.system.mapper.news.NewsTechnologyCommunicateMapper;
import com.ruoyi.system.service.news.NewsTechnologyCommunicateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsTechnologyCommunicateServiceImpl extends ServiceImpl<NewsTechnologyCommunicateMapper, NewsTechnologyCommunicate>
        implements NewsTechnologyCommunicateService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsTechnologyCommunicateVo> getNewsTechnologyCommunicateList(NewsTechnologyCommunicateQuery newsTechnologyCommunicateQuery) {
        if (newsTechnologyCommunicateQuery.getIfPage()) {
            PageHelper.startPage(newsTechnologyCommunicateQuery.getPageNum(), newsTechnologyCommunicateQuery.getPageSize());
        }
        List<NewsTechnologyCommunicateVo> newsTechnologyCommunicateVoList = baseMapper.getNewsTechnologyCommunicateList(newsTechnologyCommunicateQuery);
        if (!newsTechnologyCommunicateVoList.isEmpty() && newsTechnologyCommunicateQuery.getId() == null) {
            for (NewsTechnologyCommunicateVo newsTechnologyCommunicateVo:newsTechnologyCommunicateVoList) {
                newsTechnologyCommunicateVo.setContent(null);
            }
        }
        return newsTechnologyCommunicateVoList;
    }
}
